package main

import (
	"fmt"
	"strconv"
)

/**
不是标准的函数式编程
 */
func adder() func(int) int {
	sum := 0
	return func(input int) int {
		sum += input
		var result = ""
		for i := 0; i <= input; i++ {
			if i != 0{
				result += " + "
			}
			// result += strconv.FormatInt(int64(i),10)
			result += strconv.Itoa(i)
		}
		fmt.Print(result)
		return sum
	}
}

func main() {
	adder := adder()
	for i := 0; i < 10; i++ {
		fmt.Println(" = ", adder(i))
	}
}
